#!/bin/sh
#
# PROVIDE: pbid
# REQUIRE: DAEMON devd
# KEYWORD: shutdown
#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# pbid_enable="YES"
#

. /etc/rc.subr

: ${pbid_enable="NO"}

name=pbid
rcvar="pbid_enable"
pidfile="/var/run/${name}.pid"

command=/usr/local/sbin/pbid
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
start_cmd="pbid_start"
stop_cmd=pbid_stop

pbid_start()
{
	if ! checkyesno pbid_enable ; then
		return 0
	fi

	echo "Starting ${name}..."

	/usr/sbin/daemon -f -p ${pidfile} ${command}
}

pbid_stop()
{
	if ! checkyesno pbid_enable; then
		return;
	fi
	
	if [ ! -e "$pidfile" ] ; then
		echo "No $pidfile, is $name running?"
		return;
	fi

	echo "Stopping ${name}..."
        kill -9 "`cat ${pidfile}`"
	rm -f "${pidfile}"
}


load_rc_config ${name}
run_rc_command "$1" 
